home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Utilities / BenchMarks / Dhrystone / README < prev    next >
Text File  |  1993-01-25  |  18KB  |  372 lines

  1.  
  2.  
  3.     Dhrystone Benchmark: Rationale for Version 2 and Measurement Rules
  4.  
  5.  
  6.                  Reinhold P. Weicker
  7.                  Siemens AG, E STE 35
  8.                  Postfach 3240
  9.                  D-8520 Erlangen
  10.                  Germany (West)
  11.  
  12.  
  13.  
  14.  
  15. 1.  Why a Version 2 of Dhrystone?
  16.  
  17. The Dhrystone benchmark program [1] has become a popular benchmark  for
  18. CPU/compiler  performance  measurement,  in  particular  in the area of
  19. minicomputers, workstations, PC's and  microprocesors.   It  apparently
  20. satisfies a need for an easy-to-use integer benchmark; it gives a first
  21. performance indication which  is  more  meaningful  than  MIPS  numbers
  22. which,  in  their  literal  meaning  (million instructions per second),
  23. cannot be used across different instruction sets (e.g. RISC vs.  CISC).
  24. With  the  increasing  use  of  the  benchmark,  it  seems necessary to
  25. reconsider the benchmark and to check whether it can still fulfill this
  26. function.   Version  2  of  Dhrystone  is  the  result  of  such  a re-
  27. evaluation, it has been made for two reasons:
  28.  
  29. o Dhrystone has been published in Ada [1], and Versions in Ada,  Pascal
  30.   and  C  have  been  distributed  by Reinhold Weicker via floppy disk.
  31.   However, the version that was used most often  for  benchmarking  has
  32.   been  the version made by Rick Richardson by another translation from
  33.   the Ada version into the C programming language, this  has  been  the
  34.   version distributed via the UNIX network Usenet [2].
  35.  
  36.   There is an obvious need for a common C version of Dhrystone, since C
  37.   is  at  present  the most popular system programming language for the
  38.   class of systems (microcomputers, minicomputers, workstations)  where
  39.   Dhrystone  is  used  most.  There should be, as far as possible, only
  40.   one C version of Dhrystone such that results can be compared  without
  41.   restrictions.  In  the  past,  the  C  versions  distributed  by Rick
  42.   Richardson (Version 1.1) and by Reinhold Weicker  had  small  (though
  43.   not significant) differences.
  44.  
  45.   Together with the new C version, the Ada  and  Pascal  versions  have
  46.   been updated as well.
  47.  
  48. o As far as it is possible without changes to the Dhrystone statistics,
  49.   optimizing  compilers  should  be prevented from removing significant
  50.   statements.  It has turned out in the past that optimizing  compilers
  51.   suppressed  code  generation  for  too many statements (by "dead code
  52.   removal" or "dead variable  elimination").   This  has  lead  to  the
  53.   danger  that  benchmarking results obtained by a naive application of
  54.   Dhrystone - without inspection of the code that was generated - could
  55.   become meaningless.
  56.  
  57. The overall policiy for version 2 has been  that  the  distribution  of
  58. statements,  operand types and operand locality described in [1] should
  59. remain  unchanged  as  much  as  possible.   (Very  few  changes   were
  60. necessary;  their  impact  should  be  negligible.)  Also, the order of
  61. statements should  remain  unchanged.  Although  I  am  aware  of  some
  62. critical  remarks on the benchmark - I agree with several of them - and
  63. know some suggestions for improvement, I  didn't  want  to  change  the
  64. benchmark  into  something  different  from  what  has  become known as
  65. "Dhrystone"; the confusion generated by such a  change  would  probably
  66. outweight  the  benefits. If I were to write a new benchmark program, I
  67. wouldn't give it the name "Dhrystone" since this  denotes  the  program
  68. published in [1].  However, I do recognize the need for a larger number
  69. of representative programs that can be used as benchmarks; users should
  70. always be encouraged to use more than just one benchmark.
  71.  
  72. The  new  versions  (version  2.0  for  C,  Pascal  and  Ada)  will  be
  73. distributed  as  widely  as  possible.   Readers  who  want  to use the
  74. benchmark for their own measurements can  obtain  a  copy  in  machine-
  75. readable  form on floppy disk (MS-DOS or XENIX format) from the author.
  76. In addition, the new versions have been  posted  to  the  UNIX  network
  77. Usenet.
  78.  
  79.  
  80. 2.  Overall Characteristics of Version 2
  81.  
  82. In general, version 2 follows - in the parts that are  significant  for
  83. performance  measurement,  i.e.   within  the  measurement  loop  - the
  84. published (Ada) version and  the  C  versions  previously  distributed.
  85. Where  the  versions  distributed  by  Rick Richardson [2] and Reinhold
  86. Weicker have been different, it  follows  the  version  distributed  by
  87. Reinhold  Weicker.  (However,  the  differences have been so small that
  88. their impact on execution time in all likelihood has been  negligible.)
  89. The  initialization  and  UNIX  instrumentation  part  - which had been
  90. omitted in [1] - follows mostly  the  ideas  of  Rick  Richardson  [2].
  91. However,  any changes in the initialization part and in the printing of
  92. the result have no impact on performance  measurement  since  they  are
  93. outside  the  measaurement  loop.   As a concession to older compilers,
  94. names have been made unique within the first 8  characters  for  the  C
  95. version.
  96.  
  97. The original publication of Dhrystone did not  contain  any  statements
  98. for  time  measurement  since  they  are  necessarily system-dependent.
  99. However, it turned out that it is not enough just to inclose  the  main
  100. procedure of Dhrystone in a loop and to measure the execution time.  If
  101. the variables that are computed are not  used  somehow,  there  is  the
  102. danger  that  the  compiler  considers  them  as  "dead  variables" and
  103. suppresses code generation for a part of the statements.  Therefore  in
  104. version  2  all  variables  of  "main"  are  printed  at the end of the
  105. program. This  also  permits  some  plausibility  control  for  correct
  106. execution of the benchmark.
  107.  
  108. At several places in the benchmark, code has been added,  but  only  in
  109. branches  that  are  not  executed.  The  intention  is that optimizing
  110. compilers should be prevented from moving code out of  the  measurement
  111. loop,  or  from  removing code altogether. Statements that are executed
  112. have been changed in very few places only.  In these  cases,  only  the
  113. role  of  some operands has been changed, and it was made sure that the
  114. numbers  defining  the  "Dhrystone   distribution"   (distribution   of
  115. statements, operand types and locality) still hold as much as possible.
  116. Except for sophisticated  optimizing  compilers,  execution  times  for
  117. version 2.0 should be the same as for previous versions.
  118.  
  119. Because of the self-imposed limitation that the order and  distribution
  120. of the executed statements should not be changed, there are still cases
  121. where optimizing compilers may not generate code for  some  statements.
  122. To   a   certain  degree,  this  is  unavoidable  for  small  synthetic
  123. benchmarks.  Users of the benchmark are advised to check code  listings
  124. whether code is generated for all statements of Dhrystone.
  125.  
  126. Contrary to the suggestion in the published paper and  its  realization
  127. in  the  versions  previously  distributed, no attempt has been made to
  128. subtract the time for the measurement loop overhead. (This  calculation
  129. has  proven  difficult  to implement in a correct way, and its omission
  130. makes the program simpler.) However, since the loop check is  now  part
  131. of  the benchmark, this does have an impact - though a very minor one -
  132. on the  distribution  statistics  which  have  been  updated  for  this
  133. version.
  134.  
  135.  
  136. 3.  Discussion of Individual Changes
  137.  
  138. In this section, all changes are described that affect the  measurement
  139. loop and that are not just renamings of variables. All remarks refer to
  140. the C version; the other language versions have been updated similarly.
  141.  
  142. In addition to adding the measurement loop and the printout statements,
  143. changes have been made at the following places:
  144.  
  145. o In procedure "main", three statements have been  added  in  the  non-
  146.   executed "then" part of the statement
  147.  
  148.         if (Enum_Loc == Func_1 (Ch_Index, 'C'))
  149.  
  150.   they are
  151.  
  152.         strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 3'RD STRING");
  153.         Int_2_Loc = Run_Index;
  154.         Int_Glob = Run_Index;
  155.  
  156.   The string assignment prevents movement of the  preceding  assignment
  157.   to  Str_2_Loc  (5'th statement of "main") out of the measurement loop
  158.   (This probably will not happen for the C version, but it  did  happen
  159.   with  another  language  and  compiler.)  The assignment to Int_2_Loc
  160.   prevents value propagation  for  Int_2_Loc,  and  the  assignment  to
  161.   Int_Glob  makes  the  value  of  Int_Glob possibly dependent from the
  162.   value of Run_Index.
  163.  
  164. o In the three arithmetic computations at the end  of  the  measurement
  165.   loop  in  "main  ", the role of some variables has been exchanged, to
  166.   prevent the division from just cancelling out the  multiplication  as
  167.   it  was in [1].  A very smart compiler might have recognized this and
  168.   suppressed code generation for the division.
  169.  
  170. o For Proc_2, no code has been changed, but the values  of  the  actual
  171.   parameter have changed due to changes in "main".
  172.  
  173. o In Proc_4, the second assignment has been changed from
  174.  
  175.         Bool_Loc = Bool_Loc | Bool_Glob;
  176.  
  177.   to
  178.  
  179.         Bool_Glob = Bool_Loc | Bool_Glob;
  180.  
  181.   It now assigns a value to  a  global  variable  instead  of  a  local
  182.   variable (Bool_Loc); Bool_Loc would be a "dead variable" which is not
  183.   used afterwards.
  184.  
  185. o In Func_1, the statement
  186.  
  187.         Ch_1_Glob = Ch_1_Loc;
  188.  
  189.   was added in the non-executed "else" part of the "if"  statement,  to
  190.   prevent  the  suppression  of  code  generation for the assignment to
  191.   Ch_1_Loc.
  192.  
  193. o In Func_2, the second character comparison statement has been changed
  194.   to
  195.  
  196.         if (Ch_Loc == 'R')
  197.  
  198.   ('R' instead of 'X') because a comparison with 'X' is implied in  the
  199.   preceding "if" statement.
  200.  
  201.   Also in Func_2, the statement
  202.  
  203.         Int_Glob = Int_Loc;
  204.  
  205.   has been added in the non-executed part of the last  "if"  statement,
  206.   in order to prevent Int_Loc from becoming a dead variable.
  207.  
  208. The distribution statistics have been changed only by the  addition  of
  209. the  measurement  loop  iteration (1 additional statement, 4 additional
  210. local integer operands) and  by  the  change  in  Proc_4  (one  operand
  211. changed  from  local  to  global).  The  distribution statistics in the
  212. comment headers have been updated accordingly.
  213.  
  214.  
  215. 4.  String Operations
  216.  
  217. The string operations (string assignment and  string  comparison)  have
  218. not  been  changed,  to  keep  the program consistent with the original
  219. version.
  220.  
  221. There has been some  concern  that  the  string  operations  are  over-
  222. represented  in  the  program,  and that execution time is dominated by
  223. these  operations.   This  was  true  in  particular  when   optimizing
  224. compilers  removed  too much code in the main part of the program, this
  225. should have been mitigated in version 2.
  226.  
  227. It should be noted that this is a language-dependent issue:   Dhrystone
  228. was  first published in Ada, and with Ada or Pascal semantics, the time
  229. spent in the string operations is,  at  least  in  all  implementations
  230. known  to  me, considerably smaller.  In Ada and Pascal, assignment and
  231. comparison of strings are operators defined in the  language,  and  the
  232. upper  bounds of the strings occuring in Dhrystone are part of the type
  233. information known at compilation time.   The  compilers  can  therefore
  234. generate efficient inline code.  In C, string assignemt and comparisons
  235. are not part of the language, so the C library functions  "strcpy"  and
  236. "strcmp"  have  to  be used.  In addition to the overhead caused by two
  237. additional function  calls,  these  functions  are  defined  for  null-
  238. terminated  strings  where  the  length  of the strings is not known at
  239. compilation time;  the  function  has  to  check  every  byte  for  the
  240. termination condition (the null byte).
  241.  
  242. Obviously, a C library which includes efficiently  coded  "strcpy"  and
  243. "strcmp"  functions  helps to obtain good Dhrystone results. However, I
  244. don't think that this is unfair since string functions do  occur  quite
  245. frequently  in real programs (editors, command interpreters, etc.).  If
  246. the strings functions are  implemented  efficiently,  this  helps  real
  247. programs as well as benchmark programs.
  248.  
  249. I admit that the string comparison in Dhrystone terminates later (after
  250. scanning  20 characters) than most string comparisons in real programs.
  251. For consistency with  the  original  benchmark,  I  didn't  change  the
  252. program despite this weakness.
  253.  
  254.  
  255. 5.  Intended Use of Dhrystone
  256.  
  257. When Dhrystone is used, the following "ground rules" apply:
  258.  
  259. o Separate compilation (Ada and C versions)
  260.  
  261.   As  mentioned  in  [1],  Dhrystone  was  written  to  reflect  actual
  262.   programming  practice  in  systems  programming.   The  division into
  263.   several compilation units (5 in the Ada version, 3 in the C  version)
  264.   is  intended, as is the distribution of inter-module and intra-module
  265.   subprogram  calls.   Although  on  many  systems  there  will  be  no
  266.   difference  in  execution  time  to  a  Dhrystone  version  where all
  267.   compilation units are merged into one file, the rule is that separate
  268.   compilation  should  be used.  The intention is that real programming
  269.   practice, where programs consist of  several  independently  compiled
  270.   units, should be reflected.  This also has implies that the compiler,
  271.   while compiling one  unit,  has  no  information  about  the  use  of
  272.   variables,  register  allocation  etc.  occuring in other compilation
  273.   units.  Although in real life  compilation  units  will  probably  be
  274.   larger,  the  intention is that these effects of separate compilation
  275.   are modeled in Dhrystone.
  276.  
  277.   A few  language  systems  have  post-linkage  optimization  available
  278.   (e.g.,  final  register allocation is performed after linkage).  This
  279.   is a borderline case: Post-linkage optimization  involves  additional
  280.   program  preparation time (although not as much as compilation in one
  281.   unit) which may prevent its general use in practical programming.   I
  282.   think that since it defeats the intentions given above, it should not
  283.   be used for Dhrystone.
  284.  
  285.   Unfortunately, ISO/ANSI Pascal does not contain language features for
  286.   separate  compilation.   Although  most  commercial  Pascal compilers
  287.   provide separate compilation in  some  way,  we  cannot  use  it  for
  288.   Dhrystone  since such a version would not be portable.  Therefore, no
  289.   attempt has been made  to  provide  a  Pascal  version  with  several
  290.   compilation units.
  291.  
  292. o No procedure merging
  293.  
  294.   Although  Dhrystone  contains  some  very  short   procedures   where
  295.   execution  would  benefit  from  procedure  merging  (inlining, macro
  296.   expansion of procedures), procedure merging is not to be  used.   The
  297.   reason is that the percentage of procedure and function calls is part
  298.   of the "Dhrystone distribution" of statements contained in [1].
  299.  
  300. o Other optimizations are allowed, but they should be indicated
  301.  
  302.   It is  often  hard  to  draw  an  exact  line  between  "normal  code
  303.   generation"  and  "optimization" in compilers: Some compilers perform
  304.   operations by default that are invoked in other compilers  only  when
  305.   optimization  is explicitly requested.  Also, we cannot avoid that in
  306.   benchmarking people try to achieve  results  that  look  as  good  as
  307.   possible.   Therefore,  optimizations  performed by compilers - other
  308.   than those listed above - are not forbidden when Dhrystone  execution
  309.   times  are measured.  Dhrystone is not intended to be non-optimizable
  310.   but is intended to be similarly optimizable as normal programs.   For
  311.   example,  there  are  several  places  in Dhrystone where performance
  312.   benefits from optimizations like  Common  Subexpression  Elimination,
  313.   Value Propagation etc., but normal programs usually also benefit from
  314.   these optimizations.  Therefore, no effort was made  to  artificially
  315.   prevent  such  optimizations.   However,  measurement  reports should
  316.   indicate which compiler  optimization  levels  have  been  used,  and
  317.   reporting  results with different levels of compiler optimization for
  318.   the same hardware is encouraged.
  319.  
  320. o Default results are those without "register" declarations (C version)
  321.  
  322.   When Dhrystone results are quoted without  additional  qualification,
  323.   they  should  be  understood  as  results obtained without use of the
  324.   "register" attribute. Good compilers should be able to make good  use
  325.   of  registers  even  without  explicit register declarations ([3], p.
  326.   193).
  327.  
  328. Of  course,  for  experimental  purposes,  post-linkage   optimization,
  329. procedure  merging  and/or  compilation  in  one  unit  can  be done to
  330. determine their effects.  However,  Dhrystone  numbers  obtained  under
  331. these   conditions  should  be  explicitly  marked  as  such;  "normal"
  332. Dhrystone results should be understood as  results  obtained  following
  333. the ground rules listed above.
  334.  
  335. In any case, for serious performance evaluation, users are  advised  to
  336. ask  for  code listings and to check them carefully.  In this way, when
  337. results for different systems  are  compared,  the  reader  can  get  a
  338. feeling how much performance difference is due to compiler optimization
  339. and how much is due to hardware speed.
  340.  
  341.  
  342. 6.  Acknowledgements
  343.  
  344. The C version 2.0 of Dhrystone has been developed in  cooperation  with
  345. Rick Richardson (Tinton Falls, NJ), it incorporates many ideas from the
  346. "Version 1.1" distributed previously  by  him  over  the  UNIX  network
  347. Usenet.  Through  his  activity with Usenet, Rick Richardson has made a
  348. very valuable contribution to the dissemination of  the  benchmark.   I
  349. also  thank  Chaim  Benedelac  (National  Semiconductor),  David Ditzel
  350. (SUN), Earl Killian and John  Mashey  (MIPS),  Alan  Smith  and  Rafael
  351. Saavedra-Barrera  (UC  at  Berkeley)  for  their  help with comments on
  352. earlier versions of the benchmark.
  353.  
  354.  
  355. 7.  Bibliography
  356.  
  357. [1]
  358.    Reinhold P. Weicker:  Dhrystone:  A  Synthetic  Systems  Programming
  359.    Benchmark.
  360.    Communications of the ACM 27, 10 (Oct. 1984), 1013-1030
  361.  
  362. [2]
  363.    Rick Richardson: Dhrystone 1.1 Benchmark Summary (and Program Text)
  364.    Informal Distribution via "Usenet", Last Version Known to me:  Sept.
  365.    21, 1987
  366.  
  367. [3]
  368.    Brian W.  Kernighan  and  Dennis  M.  Ritchie:   The  C  Programming
  369.    Language.
  370.    Prentice-Hall, Englewood Cliffs (NJ) 1978
  371.  
  372.